<template>
  <div class="main">
    <el-card class="box-card cardhead" style="width: 50%;">
      <div slot="header" class="clearfix">
        <div class="mainTitle">
          <h2>基本信息</h2>
          <el-button @click="submit" style="float: right;" type="primary">保 存</el-button>
        </div> 
      </div>
      <div>
        <Form :formdata="formdata" :formobj="formobj" ref="bannerForm" :formrules="formrules"></Form>
      </div>
      <!-- <div v-for="o in 4" :key="o" class="text item">
        {{'列表内容 ' + o }}
      </div> -->
    </el-card>



    
  </div>
</template>
<script>
import { contentApiedit,contentApiqueryOne } from "@/api/webpage";
import Form from "@/components/form.vue";
export default {
  name: "information",
  components: {
    Form,
  },
  data() {
    return {
      formobj: [
        { label: "大赛介绍", key: "content", type: "textarea" },
      ],
      formdata:{},
      formrules: {
        // title: [
        //   { required: true, message: "请输入大赛简介", trigger: "blur" },
        // ],
      },
    };
  },
  created() {
    this.getdata('1FD63A2D6A454EFA97D5EEF91931CBE1')
  },
  methods: {
     getdata(id) {
      contentApiqueryOne({ id: id })
        .then((res) => {
          if (res.code == 0 && res.data) {
            this.formdata = res.data;
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
    submit(){
       this.$refs.bannerForm.getData().then(res=>{
        res.id = '1FD63A2D6A454EFA97D5EEF91931CBE1'
         contentApiedit(res).then((response) => {
              if (response.data == 1) {
                this.$message.success("成功");
              } else {
                this.$message.error("失败");
              }
            })
            .catch((err) => {
              console.log(err);
            });
        })
    },
  },
};
</script>
<style scoped>
@import "~@/assets/css/adminstyle.css";
.cardhead .el-card__header{
 padding: 0;
}
</style>
